//
//  YDContact.m
//  IngCard
//
//  Created by kf on 2017/9/7.
//  Copyright © 2017年 IngDan. All rights reserved.
//

#import "YDContact.h"

@implementation YDContact

+(NSMutableArray<YDContact *> *) serializeWithListJson:(NSArray *) dic
{
    if ((!dic) || (dic.count == 0)) return nil;
    
    NSMutableArray *result = [NSMutableArray array];
    for (int i = 0; i < dic.count; i++) {
        NSDictionary *contactDic = NSDictionaryMake(dic[i]);

        YDContact *contact = [[YDContact alloc] init];
        contact.uid = NSStringMake(contactDic[@"uid"]);
        contact.company = NSStringMake(contactDic[@"company_name"]);
        contact.occupation = NSStringMake(contactDic[@"occupation"]);
        contact.username = NSStringMake(contactDic[@"username"]);
        contact.firstName = NSStringMake(contactDic[@"first_name"]);
        contact.lastName = NSStringMake(contactDic[@"last_name"]);
        contact.headImage = NSStringMake(contactDic[@"head_pic"]);
        contact.cardId = NSStringMake(contactDic[@"cid"]);
        [result safeAddObject:contact];
    }
    return result;
}

@end
